# Pull base image
FROM ubuntu:13.10

MAINTAINER zing wang "zing.jian.wang@gmail.com"

# update source
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe"> /etc/apt/sources.list
RUN apt-get update

#install ssh
RUN apt-get install -y openssh-server
RUN mkdir -p /var/run/sshd

RUN echo "root:123456" | chpasswd

# Install curl
RUN apt-get -y install curl

#install wget
RUN apt-get -y install wget


# Install JDK 7
RUN cd /tmp &&  curl -L 'http://download.oracle.com/otn-pub/java/jdk/7u65-b17/jdk-7u65-linux-x64.tar.gz' -H 'Cookie: oraclelicense=accept-securebackup-cookie; gpw_e24=Dockerfile' | tar -xz
RUN mkdir -p /usr/lib/jvm
RUN mv /tmp/jdk1.7.0_65/ /usr/lib/jvm/java-7-oracle/

# Set Oracle JDK 7 as default Java
RUN update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-7-oracle/bin/java 300
RUN update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-7-oracle/bin/javac 300

ENV JAVA_HOME /usr/lib/jvm/java-7-oracle/

# Install tomcat7
RUN cd /tmp && curl -L 'http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.8/bin/apache-tomcat-7.0.8.tar.gz' | tar -xz
RUN mv /tmp/apache-tomcat-7.0.8/ /opt/tomcat7/

ENV CATALINA_HOME /opt/tomcat7
ENV PATH $PATH:$CATALINA_HOME/bin

ADD script/tomcat7.sh /etc/init.d/tomcat7
RUN chmod 755 /etc/init.d/tomcat7

RUN mkdir /opt/script

ADD script/deploy.sh /opt/script



# Install maven
RUN cd /tmp && curl -L 'http://mirror.metrocast.net/apache//maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz' | tar -xz
RUN mv /tmp/apache-maven-3.0.5/ /opt/apache-maven/
ENV M2_HOME /opt/tomcat7
ENV PATH $PATH:$CATALINA_HOME/bin

#install git
#RUN apt-get install -y git
#
#RUN mkdir /opt/git
#RUN git clone https://git.oschina.net/romin/wxAdPlatform.git

# Expose ports.
# RUN cd /opt/tomcat7/webapps/ROOT/ && rm ./*.*


RUN cd /opt/ && wget 'http://o6r5b9fpl.bkt.clouddn.com/wxAdsPlatform-1.3.3.RELEASE.war'
EXPOSE 8080

EXPOSE 22

# Define default command.
ENTRYPOINT java -jar "/opt/wxAdsPlatform-1.3.3.RELEASE.war">/opt/stdout.log
